

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>opt - LLVM optimizer &mdash; LLVM 3.2 documentation</title>
    
    <link rel="stylesheet" href="../_static/llvm-theme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="LLVM 3.2 documentation" href="../index.html" />
    <link rel="up" title="LLVM Command Guide" href="index.html" />
    <link rel="next" title="llc - LLVM static compiler" href="llc.html" />
    <link rel="prev" title="llvm-dis - LLVM disassembler" href="llvm-dis.html" />
<style type="text/css">
  table.right { float: right; margin-left: 20px; }
  table.right td { border: 1px solid #ccc; }
</style>

  </head>
  <body>
<div class="logo">
  <a href="../index.html">
    <img src="../_static/logo.png"
         alt="LLVM Logo" width="250" height="88"/></a>
</div>

    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="llc.html" title="llc - LLVM static compiler"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="llvm-dis.html" title="llvm-dis - LLVM disassembler"
             accesskey="P">previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li><a href="../userguides.html" >User Guides</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">LLVM Command Guide</a> &raquo;</li> 
      </ul>
    </div>

      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">opt - LLVM optimizer</a><ul>
<li><a class="reference internal" href="#synopsis">SYNOPSIS</a></li>
<li><a class="reference internal" href="#description">DESCRIPTION</a></li>
<li><a class="reference internal" href="#options">OPTIONS</a></li>
<li><a class="reference internal" href="#exit-status">EXIT STATUS</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="llvm-dis.html"
                        title="previous chapter">llvm-dis - LLVM disassembler</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="llc.html"
                        title="next chapter">llc - LLVM static compiler</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/CommandGuide/opt.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="opt-llvm-optimizer">
<h1>opt - LLVM optimizer<a class="headerlink" href="#opt-llvm-optimizer" title="Permalink to this headline">¶</a></h1>
<div class="section" id="synopsis">
<h2>SYNOPSIS<a class="headerlink" href="#synopsis" title="Permalink to this headline">¶</a></h2>
<p><strong>opt</strong> [<em>options</em>] [<em>filename</em>]</p>
</div>
<div class="section" id="description">
<h2>DESCRIPTION<a class="headerlink" href="#description" title="Permalink to this headline">¶</a></h2>
<p>The <strong>opt</strong> command is the modular LLVM optimizer and analyzer.  It takes LLVM
source files as input, runs the specified optimizations or analyses on it, and then
outputs the optimized file or the analysis results.  The function of
<strong>opt</strong> depends on whether the <strong>-analyze</strong> option is given.</p>
<p>When <strong>-analyze</strong> is specified, <strong>opt</strong> performs various analyses of the input
source.  It will usually print the results on standard output, but in a few
cases, it will print output to standard error or generate a file with the
analysis output, which is usually done when the output is meant for another
program.</p>
<p>While <strong>-analyze</strong> is <em>not</em> given, <strong>opt</strong> attempts to produce an optimized
output file.  The optimizations available via <strong>opt</strong> depend upon what
libraries were linked into it as well as any additional libraries that have
been loaded with the <strong>-load</strong> option.  Use the <strong>-help</strong> option to determine
what optimizations you can use.</p>
<p>If <em>filename</em> is omitted from the command line or is <em>-</em>, <strong>opt</strong> reads its
input from standard input. Inputs can be in either the LLVM assembly language
format (.ll) or the LLVM bitcode format (.bc).</p>
<p>If an output filename is not specified with the <strong>-o</strong> option, <strong>opt</strong>
writes its output to the standard output.</p>
</div>
<div class="section" id="options">
<h2>OPTIONS<a class="headerlink" href="#options" title="Permalink to this headline">¶</a></h2>
<p><strong>-f</strong></p>
<blockquote>
<div>Enable binary output on terminals.  Normally, <strong>opt</strong> will refuse to
write raw bitcode output if the output stream is a terminal. With this option,
<strong>opt</strong> will write raw bitcode regardless of the output device.</div></blockquote>
<p><strong>-help</strong></p>
<blockquote>
<div>Print a summary of command line options.</div></blockquote>
<p><strong>-o</strong> <em>filename</em></p>
<blockquote>
<div>Specify the output filename.</div></blockquote>
<p><strong>-S</strong></p>
<blockquote>
<div>Write output in LLVM intermediate language (instead of bitcode).</div></blockquote>
<p><strong>-{passname}</strong></p>
<blockquote>
<div><strong>opt</strong> provides the ability to run any of LLVM&#8217;s optimization or analysis passes
in any order. The <strong>-help</strong> option lists all the passes available. The order in
which the options occur on the command line are the order in which they are
executed (within pass constraints).</div></blockquote>
<p><strong>-std-compile-opts</strong></p>
<blockquote>
<div><p>This is short hand for a standard list of <em>compile time optimization</em> passes.
This is typically used to optimize the output from the llvm-gcc front end. It
might be useful for other front end compilers as well. To discover the full set
of options available, use the following command:</p>
<div class="highlight-sh"><div class="highlight"><pre>llvm-as &lt; /dev/null | opt -std-compile-opts -disable-output -debug-pass<span class="o">=</span>Arguments
</pre></div>
</div>
</div></blockquote>
<p><strong>-disable-inlining</strong></p>
<blockquote>
<div>This option is only meaningful when <strong>-std-compile-opts</strong> is given. It simply
removes the inlining pass from the standard list.</div></blockquote>
<p><strong>-disable-opt</strong></p>
<blockquote>
<div>This option is only meaningful when <strong>-std-compile-opts</strong> is given. It disables
most, but not all, of the <strong>-std-compile-opts</strong>. The ones that remain are
<strong>-verify</strong>, <strong>-lower-setjmp</strong>, and <strong>-funcresolve</strong>.</div></blockquote>
<p><strong>-strip-debug</strong></p>
<blockquote>
<div>This option causes opt to strip debug information from the module before
applying other optimizations. It is essentially the same as <strong>-strip</strong> but it
ensures that stripping of debug information is done first.</div></blockquote>
<p><strong>-verify-each</strong></p>
<blockquote>
<div>This option causes opt to add a verify pass after every pass otherwise specified
on the command line (including <strong>-verify</strong>).  This is useful for cases where it
is suspected that a pass is creating an invalid module but it is not clear which
pass is doing it. The combination of <strong>-std-compile-opts</strong> and <strong>-verify-each</strong>
can quickly track down this kind of problem.</div></blockquote>
<p><strong>-profile-info-file</strong> <em>filename</em></p>
<blockquote>
<div>Specify the name of the file loaded by the -profile-loader option.</div></blockquote>
<p><strong>-stats</strong></p>
<blockquote>
<div>Print statistics.</div></blockquote>
<p><strong>-time-passes</strong></p>
<blockquote>
<div>Record the amount of time needed for each pass and print it to standard
error.</div></blockquote>
<p><strong>-debug</strong></p>
<blockquote>
<div>If this is a debug build, this option will enable debug printouts
from passes which use the <em>DEBUG()</em> macro.  See the <strong>LLVM Programmer&#8217;s
Manual</strong>, section <em>#DEBUG</em> for more information.</div></blockquote>
<p><strong>-load</strong>=<em>plugin</em></p>
<blockquote>
<div><p>Load the dynamic object <em>plugin</em>.  This object should register new optimization
or analysis passes. Once loaded, the object will add new command line options to
enable various optimizations or analyses.  To see the new complete list of
optimizations, use the <strong>-help</strong> and <strong>-load</strong> options together. For example:</p>
<div class="highlight-sh"><div class="highlight"><pre>opt -load<span class="o">=</span>plugin.so -help
</pre></div>
</div>
</div></blockquote>
<p><strong>-p</strong></p>
<blockquote>
<div>Print module after each transformation.</div></blockquote>
</div>
<div class="section" id="exit-status">
<h2>EXIT STATUS<a class="headerlink" href="#exit-status" title="Permalink to this headline">¶</a></h2>
<p>If <strong>opt</strong> succeeds, it will exit with 0.  Otherwise, if an error
occurs, it will exit with a non-zero value.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="llc.html" title="llc - LLVM static compiler"
             >next</a> |</li>
        <li class="right" >
          <a href="llvm-dis.html" title="llvm-dis - LLVM disassembler"
             >previous</a> |</li>
  <li><a href="http://llvm.org/">LLVM Home</a>&nbsp;|&nbsp;</li>
  <li><a href="../index.html">Documentation</a>&raquo;</li>

          <li><a href="../userguides.html" >User Guides</a> &raquo;</li>
          <li><a href="index.html" >LLVM Command Guide</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, LLVM Project.
      Last updated on 2012-12-21.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>